/* readclass/functions/ClassFile.go */
/* Written by, Sohail Qayum Malik[sqm@hackers.pk] */

package functions

type ClassFile struct {
}

/* CpInfo, Constant Pool Info */
type ClassFileBeforeCpInfo struct {

   /* They all need to get exported, I hate camel casing and every thing which is in upper case, but here it is mandatory to have the first charater capitalized */
   Magic		uint32
   MinorVersion		uint16
   MajorVersion		uint16
   ConstantPoolCount	uint16 /* number of instances of struct cp_info */
}
type ClassFileAfterCpInfo struct {

   AccessFlags		uint16
   ThisClass		uint16
   SuperClass		uint16
   InterfaceCount	uint16
}
type ClassFileAfterCpInfoAndInterfaces struct {

   FieldsCount		uint16
}

type CpInfo struct {

   Tag			byte   /* byte, an alias type of uint8 */
   Info			[]byte
}
const (

    Constant_Utf8		byte = 1
    Constant_Integer		byte = 3
    Constant_Float		byte = 4
    Constant_Long		byte = 5
    Constant_Double		byte = 6
    Constant_Class		byte = 7
    Constant_String		byte = 8
    Constant_Fieldref		byte = 9
    Constant_Methodref		byte = 10
    Constant_InterfaceMethodref byte = 11
    Constant_NameAndType	byte = 12
    /* Added later on, not in the Oracle docs */
    Constant_MethodHandle	byte = 15
    Constant_MethodType		byte = 16
    Constant_InvokeDynamic	byte = 18
)
type ConstantMethodRefInfo struct {
   //Tag				byte   /* byte, an alias of type uint8 */
   ClassIndex			uint16
   NameAndTypeIndex		uint16
}
type ConstantStringInfo struct {
   //Tag				byte
   StringIndex			uint16

}
type ConstantClassInfo struct {
   //Tag				byte
   NameIndex			uint16
}
type ConstantUtf8Info struct {
   //Tag				byte
   Length			uint16
   Bytes			[]byte
}
type ConstantNameAndTypeInfo struct {

   //Tag				byte
   NameIndex			uint16
   DescriptorIndex		uint16
}
const (
   Sizeof_Tag				byte = 1

   Sizeof_ConstantMethodRefInfo		byte = 4
   Sizeof_ConstantStringInfo		byte = 2
   Sizeof_ConstantClassInfo		byte = 2
   Sizeof_ConstantUtf8Info		byte = 2
   Sizeof_ConstantNameAndTypeInfo	byte = 4
)


